console.log("我是NODE")

const fs = require("fs")

require("fs").readFile("D:\\work_organization\\work16\\example.txt", "utf-8", (err, data) => {
    if (err) {
        console.log(err)
        return
    }
    console.log(data)
        //这里是example.txt文档，你使用了NODE的fs模板来获取了这里的内容，此 时是10月28日的晚上
})

// let data = fs.readFileSync("D:\\work_organization\\work16\\example.txt", "utf-8")
// console.log(data)


//path模块（处理文件路径）
const path = require("path")
console.log(path.sep) //路径分隔符 windows：\ linux： /
    //  \
let data = fs.readFileSync("D:" + path.sep + "work_organization" + path.sep + "work16" + path.sep + "example.txt", "utf-8")
console.log(data)
    //这里是example.txt文档，你使用了NODE的fs模板来获取了这里的内容，此 时是10月28日的晚上

//join纯拼接
let p = path.join(__dirname, "demo18.js")
console.log(p) //D:\vsc\demo18\demo18.js

//resolve
let p1 = path.resolve("aaa", "install.log")
console.log(p1) //D:\vsc\aaa\install.log

let p2 = path.resolve("demo18", "demo18.js")
console.log(p2) //D:\vsc\demo18\demo18.js

let p3 = path.resolve("/aaa", "install.log")
console.log(p3) //D:\aaa\install.log

console.log(path.basename(p1)) //install.log
console.log(path.basename(p1, ".log")) //install
console.log(path.dirname(p1)) //D:\vsc\aaa
console.log(path.extname(p1)) //.log

let res1 = path.parse("D:\\work_organization\\work16\\example.txt")
console.log(res1)
    // {
    //     root: 'D:\\',
    //     dir: 'D:\\work_organization\\work16',
    //     base: 'example.txt',
    //     ext: '.txt',
    //     name: 'example'
    //   }
console.log(__filename + '^_^') //拿到包含当前文件的路径
console.log(__dirname) //拿到不包含当前文件的路径